package src.util;

import java.util.HashMap;
import java.util.Map;
import src.util.MiniSet;

import checkers.nullness.quals.*;
import checkers.quals.DefaultLocation;
import checkers.quals.DefaultQualifier;
import checkers.javari.quals.Mutable;
import checkers.javari.quals.ReadOnly;

@DefaultQualifier(value = "checkers.nullness.quals.NonNull", locations =
{ DefaultLocation.ALL_EXCEPT_LOCALS })
public class MiniMap<K extends /*@Mutable*/Object,V> {

	private final /*@Mutable*/Map<K,V> carrier = new HashMap<K,V>();
	
	public void put(K key, V value) {
		carrier.put(key,value);
	}

	public /*@Nullable*/ V get(K key) /*@ReadOnly*/{
		return carrier.get(key);
	}
	
	public boolean containsKey(K key) /*@ReadOnly*/{
		return carrier.containsKey(key);
	}
	
	public MiniSet<K> getKeys() /*@ReadOnly*/{
		MiniSet<K> result = new MiniSet<K>();
		for(K e: carrier.keySet()) {
			result.add(e);
		}
		return result;
	}
}
